home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / zbpc_460.zip / UTILITY.EXE / KEYTRAP.DOC < prev    next >
Text File  |  1991-03-25  |  1KB  |  9 lines

  1. One of the most commonly-asked questions on the ZBasic-PC technical support is "How can I access the extended keys, like Control, Alt and Scroll Lock" from within my program?". This is a short primer, with demonstration routines in  ZBasic-PC on how to do exactly that.
  2.  
  3. Most of us are familiar with the use of INKEY$ to return the "normal keys" returned. Other keys, such as the function keys, return a string with a length of 2. These can be "decoded" by taking the right position of the string, i. e. RIGHT$ (String$,1). Distinctive codes are returned for Alt, Shift, and Control key combinations with the function keys. In ZBasic-PC, there is also the ON INKEY$ statement to handle these keys.
  4.  
  5. The actual state of the other eight keys, Left Shift, Right Shift, Control, Alt, Caps Lock, Num Lock, Scroll Lock, and Insert are slightly trickier. Their status is held in memory locations 417 and 418 Hex and can be viewed with PEEKs of those locations. ZBasic-PC simplifies this process by providing the USR3(2) function. The BIN$ conversion can be used to view the bit settings, or values can be decoded as powers of 2. Both types of trapping are demonstrated in the example "monitor" program.
  6.  
  7. The following is code which will decode the various key combinations.
  8.  
  9.